package com.stylefeng.guns.modular.hhtb.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
import com.stylefeng.guns.modular.hhtb.model.LogMailccDto;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.hhtb.model.LogHhtbe;
import com.stylefeng.guns.modular.hhtb.service.ILogHhtbeService;

import java.util.List;
import java.util.Map;

/**
 * 交易所复投流水控制器
 *
 * @author fengshuonan
 * @Date 2018-08-27 13:59:26
 */
@Controller
@RequestMapping("/logHhtbe")
public class LogHhtbeController extends BaseController {

    private String PREFIX = "/hhtb/logHhtbe/";

    @Autowired
    private ILogHhtbeService logHhtbeService;

    /**
     * 跳转到交易所复投流水首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "logHhtbe.html";
    }

    /**
     * 跳转到添加交易所复投流水
     */
    @RequestMapping("/logHhtbe_add")
    public String logHhtbeAdd() {
        return PREFIX + "logHhtbe_add.html";
    }

    /**
     * 跳转到修改交易所复投流水
     */
    @RequestMapping("/logHhtbe_update/{logHhtbeId}")
    public String logHhtbeUpdate(@PathVariable Integer logHhtbeId, Model model) {
        LogHhtbe logHhtbe = logHhtbeService.selectById(logHhtbeId);
        model.addAttribute("item",logHhtbe);
        LogObjectHolder.me().set(logHhtbe);
        return PREFIX + "logHhtbe_edit.html";
    }

    /**
     * 获取交易所复投流水列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(LogHhtbe logHhtbe) {
        Page<Map<String,Object>> page = new PageFactory<Map<String,Object>>().defaultPage();
        List<Map<String, Object>> articlesList= logHhtbeService.selectLogHhtbeList(page,logHhtbe);
        page.setRecords(articlesList);
        return super.packForBT(page);
    }

    /**
     * 新增交易所复投流水
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(LogHhtbe logHhtbe) {
        logHhtbeService.insert(logHhtbe);
        return SUCCESS_TIP;
    }

    /**
     * 删除交易所复投流水
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer logHhtbeId) {
        logHhtbeService.deleteById(logHhtbeId);
        return SUCCESS_TIP;
    }

    /**
     * 修改交易所复投流水
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(LogHhtbe logHhtbe) {
        logHhtbeService.updateById(logHhtbe);
        return SUCCESS_TIP;
    }

    /**
     * 交易所复投流水详情
     */
    @RequestMapping(value = "/detail/{logHhtbeId}")
    @ResponseBody
    public Object detail(@PathVariable("logHhtbeId") Integer logHhtbeId) {
        return logHhtbeService.selectById(logHhtbeId);
    }
}
